package com.lwq.designpattern.structuralPatterns.flyweightPattern;

import java.util.HashMap;

/**
 * @author liwq
 * @description
 * @date 2021/11/29 14:39
 */
public class ChessFactory {
    private static final HashMap<String, Chess> chessCacheMap = new HashMap<>();

    public static Chess getCircle(String color) {
        FiveInARowChess chess = (FiveInARowChess)chessCacheMap.get(color);
        if (chess == null) {
            chess = new FiveInARowChess(color);
            chessCacheMap.put(color, chess);
            System.out.println("创建五子棋实例 : " + color);
        }
        return chess;
    }
}
